﻿using System;
using System.Configuration;
using System.Xml;

namespace Atom.Common.CustomConfiguration
{
    public class NameTypeConfigurationElement : ConfigurationElement
    {    
        [ConfigurationProperty("name", IsRequired = true, IsKey = true)]
        public string Name
        {
            get
            {
                return (string)this["name"];
            }
            set
            {
                this["name"] = value;
            }
        }

        [ConfigurationProperty("type", IsRequired = true)]
        public string TypeName
        {
            get
            {
                return (string)this["type"];
            }
            set
            {
                this["type"] = value;
            }
        }

        public Type Type
        {
            get
            {
                return Type.GetType(this.TypeName);
            }
        }

        public void DeserializeElement(XmlReader reader)
        {
            base.DeserializeElement(reader, false);
        }
    }
}